﻿using AFanDa.BLL.BLLService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AFanDa.Admin.Controllers
{
    /// <summary>
    /// 卡券管理
    /// </summary>
    public class KaardivautserController : Controller
    {

        CardService _cardService = null;
        /// <summary>
        /// 初始化类
        /// </summary>
        public KaardivautserController()
        {
            _cardService = new CardService();
        }


        // GET: Kaardivautser
        /// <summary>
        /// 详情页面
        /// </summary>
        /// <returns></returns>
        public ActionResult KaardivautserHtml()
        {
            return View();
        }


        /// <summary>
        /// 添加卡券
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult KaardivautserAdd(Dto.Request.CardRequestDto dto)
        {
            var result = _cardService.AddCard(dto);

            return Json(result);
        }

        /// <summary>
        /// 添加卡券页面
        /// </summary>
        /// <returns></returns>
        public ActionResult KaardivautserAddHtml()
        {
            return View();
        }
        /// <summary>
        /// 获取所有卡券
        /// </summary>
        /// <returns></returns>

        [HttpPost]
        public ActionResult GetAllCard(string key, int page = 1, int limit = 10)
        {
            key = key ?? "";
            var result = _cardService.GetCards(new Dto.Request.CardRequestDto()
            {
                key = key,
                page = 1,
                limit = limit
            });


            return Json(result);


        }

    }
}